import axios from 'axios';
import {operationCtx} from "../../../utils/auth";
import store from "@/store";

// const apiUrl = 'http://www.x3-clover.com/apiv2/';
// const apiUrlReport = 'http://www.x3-clover.com/apiv2/';

//南京测试环境
//后台管理
const apiUrl = 'http://10.135.56.101:9011/backend/behavior/';
//后台计算
const apiUrlReport = 'http://10.135.56.101:9021/backend/compute/';

// post
export function postAction(url, parameter, t) {
    parameter['operationCtx'] = operationCtx;
    parameter['req']['appId'] = store.state.global.appId;
    parameter['req']['requestId'] = require('node-uuid').v1();
    return axios({url: url, method: 'post', data: parameter});
}


//事件分组
// const thinglGroup = (params) => postAction(apiUrl + 'events/groups/list', params);
const thinglGroup = (params) => postAction(apiUrl + 'meta/event/group/list', params);

//事件列表
const thinglList = (params) => postAction(apiUrl + 'events/all', params);

//属性列表
const propertyList = (params) => postAction(apiUrl + `property/properties`, params);

//属性值查询
const valueList = (params) => postAction(apiUrl + "property/values", params);

//分析计算
const searchData = (params) => postAction(apiUrlReport + "interval/report", params);


export {
    thinglList,
    propertyList,
    valueList,
    thinglGroup,
    searchData
};
